﻿using UnityEngine;

namespace Core
{
    public class GameObjectComponent<T> : Component
        where T : GameObjectEntity
    {
        public T Unit { get; private set; }

        public virtual void Awake()
        {
            Unit = Entity as T;
            Debug.Assert(Unit != null);
        }

        public override void Dispose()
        {
            if (IsDisposed) return;
            Unit = null;
            base.Dispose();
        }
    }
}